package org.delphy.indy2.containers.carbonTabDockClasses
{
	import mx.controls.Button;
	import mx.events.PropertyChangeEvent;
	
	import flash.events.MouseEvent;

	public class CarbonTabWidget extends Button
	{
		
		private var _themeColor : Number;

		[Bindable(event="propertyChange")]
		public function get themeColor() : Number { 
			return _themeColor; 
		}

		public function set themeColor( value:Number ) : void {
			var oldValue : Number = _themeColor;
			if (value !== oldValue){
				_themeColor = value;
				
				setStyle("indicatorColor",_themeColor);
				setStyle("textRollOverColor",_themeColor);
				setStyle("textSelectedColor",_themeColor);
				
				dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "themeColor", oldValue, value));
			}
		}
		
		public function CarbonTabWidget()
		{
			super();
			
			styleName="carbonTabWidget";
			
			toggle=true;
			
			addEventListener(MouseEvent.CLICK,onClick);
		}
		override protected function commitProperties():void{
			super.commitProperties();
			
			if(selected){
				setStyle("color",_themeColor);
			}
			else{
				setStyle("color",0xCCCCCC);
			}
			
		}
		
		private function onClick(evt:MouseEvent):void{
			if(selected){
				setStyle("color",_themeColor);
			}
			else{
				setStyle("color",0xCCCCCC);
			}
			
		}
		
	}
}